using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

using Impact.Infrastructure.Logging;

namespace Impact.UnitTests.Mocks
{
    public class MockLogger : ILogger
    {

        private List<MockLogEntry> messages;

        public MockLogger()
        {
            messages = new List<MockLogEntry>();
        }

        #region ILogger Members

        public void Write(string message)
        {
            messages.Add(new MockLogEntry(message));
        }

        public void Write(string message, TraceEventType severity)
        {
            MockLogEntry e = new MockLogEntry(message);
            e.Severity = severity;
            messages.Add(e);
        }

        public void Write(Exception ex)
        {
            messages.Add(new MockLogEntry(ex));
        }

        #endregion

        public List<MockLogEntry> Messages
        {
            get { return messages; }
        }

        public struct MockLogEntry
        {
            public MockLogEntry(string message)
            {
                this.Message = message;
                this.Exception = null;
                this.Severity = TraceEventType.Information;
            }

            public MockLogEntry(Exception ex)
            {
                this.Message = null;
                this.Exception = ex;
                this.Severity = TraceEventType.Information;
            }

            public string Message;
            public Exception Exception;
            public TraceEventType Severity;
        }
    }
}
